const express = require('express');
const router = express.Router();
const mongoose = require('mongoose');

const tuyere = require('../model/tuyere');



router.get('/find',async (req,res)=>{

    const { startDate, endDate } = req.query;


    let response = {
        code: 0,
        data: {},
        msg: '',
    };


    const dateFilter = {};
    if (startDate) {
        dateFilter.date = { $gte: new Date(startDate) };
    }
    if (endDate) {
        dateFilter.date = { ...dateFilter.date, $lte: new Date(endDate) };
    }


    try{
        let rows = await tuyere.tuyereModel.find(dateFilter).select(" -_id -__v")

        response.data = rows;

    } catch(e) {
        response.code = 1;
        response.msg = e;
    }

    res.send(response)
})



module.exports = router;